//
// create by xutao
// 通讯字节流信息
//

#define MAXTRAJECTORY 100

struct StateQuantityInformation {
    StateQuantityInformation(){
        x_ = 0;
        y_ = 0;
        heading_ = 0;
        speed_ = 0;
        thr_ = 0;
        brake_ = 0;
        steer_ = 0;
        model_ = 1;
        soc_ = 99;
    }

    StateQuantityInformation(double x, double y, float h, float v):x_(x), y_(y), heading_(h), speed_(v){}

    StateQuantityInformation(double x, double y, float h, float v, float thr, float brake, float steer){
        x_ = x;
        y_ = y;
        heading_ = h;
        speed_ = v;
        thr_ = thr;
        brake_ = brake;
        steer_ = steer;
        model_ = 1;
        soc_ = 99;
    }

    StateQuantityInformation(double x, double y, float h, float v, float thr, float brake, float steer, int model, int soc) {
        x_ = x;
        y_ = y;
        heading_ = h;
        speed_ = v;
        thr_ = thr;
        brake_ = brake;
        steer_ = steer;
        model_ = model;
        soc_ = soc;
    }

    // 车辆状态量信息
    double x_;
    double y_;
    float heading_;
    float speed_;
    float thr_;
    float brake_;
    float steer_;
    int model_;
    int soc_;
};

struct RunningState {
    //单片机状态信息

    RunningState(){
        rtk_ = false;
        location_ = false;
        remote_control_ = false;
        singlechip_ = false;
    }

    RunningState(bool rtk, bool location, bool remote_control, bool singlechip){
        rtk_ = rtk;
        location_ = location;
        remote_control_ = remote_control;
        singlechip_ = singlechip;
    }

    bool rtk_;
    bool location_;
    bool remote_control_;
    bool singlechip_;
};

struct IndustrialState :RunningState{
    // 继承RunningState，其表示工控机状态信息

    IndustrialState(bool rtk, bool location, bool remote_control, bool singlechip, int order) {
        rtk_ = rtk;
        location_ = location;
        remote_control_ = remote_control;
        singlechip_ = singlechip;
        order_ = order;
    }

    int order_;
};

struct OrderFromUpper {
    // 上位机指令
    // 此处order为标志位
    // 0， 1， 2， 3 等均为标志指令信息，减少传输数据量，便于修改
    // bool标志上位机是否正常工作

    OrderFromUpper(int order, bool upper): order_(order), upper_start_(upper){}

    int order_;
    bool upper_start_;
};

struct TrajectoryInformation {
    // 车辆单条轨迹信息

    TrajectoryInformation(){
        x_ = 0.0;
        y_ = 0.0;
        heading_ = 0.0;
        speed_ = 0.0;
        num_ = 0;
    }

    TrajectoryInformation(double x, double y, float h, float v, int num) {
        x_ = x;
        y_ = y;
        heading_ = h;
        speed_ = v;
        num_ = num;
    }

    double x_;
    double y_;
    float heading_;
    float speed_;
    int num_;
};

struct PieceOfTrajectory {

    PieceOfTrajectory(){
        now_point_ = 0;
        for (auto & i : trajectory_)
            i = TrajectoryInformation();
    }

    PieceOfTrajectory(TrajectoryInformation tra){
        now_point_ = 0;
        for (auto & i : trajectory_)
            i = TrajectoryInformation();
        trajectory_[now_point_] = tra;

    }

    bool add_trajectory(TrajectoryInformation &add_tra) {
        if (now_point_ > MAXTRAJECTORY)
            return false;
        else {
            trajectory_[now_point_] = add_tra;
            now_point_++;
            return true;
        }
    }

    TrajectoryInformation trajectory_[MAXTRAJECTORY];
    int now_point_;
};
